class EventManager
	def initialize(id)
		@id=id.to_s
	end
	def events_of_friends
		Event.find(:all,:conditions=>["person_id in (select friend_id from friends where person_id=>:person_id)",{:person_id=>@id}],:order=>'created_at desc')
	end
	def my_events
		his_events(@id)
	end
	def his_events(person_id)
		Event.find(:all,:conditions=>["person_id = :person_id",{:person_id=>person_id}],:order=>'created_at desc')
	end
	def post_article(article)
		e=Event.new
		e.person_id=article.person_id
		e.event_type=Event::POST
		e.item_id=article.id
		e.item_title=article.title
		e.item_content=article.body[0..254]
		e.save
	end
	def post_comment(article_comment)
		e=Event.new
		e.person_id=article_comment.person_id
		e.event_type=Event::COMMENT
		e.item_id=article_comment.id
		e.target_id=article_comment.article_id
		e.item_title=article_comment.article.title
		e.item_content=article_comment.body[0..254]
		e.save
	end
end